package com.scu.phototabuser.ui.login.login;

import android.graphics.Color;
import android.os.Build;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.scu.phototabuser.R;
import com.scu.phototabuser.util.FragmentUtil;

public class LoginActivity extends AppCompatActivity {

    private LoginContract.Presenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //设置状态栏透明
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }

        //加载Fragment
        LoginFragment login=LoginFragment.newInstance();
        mPresenter=new LoginPresenter(login);

        FragmentUtil.addFragmentToActivity(getFragmentManager(),R.id.container,login,"loginFragment",true);

    }

    @Override
    public void onBackPressed() {
        if (getFragmentManager().getBackStackEntryCount()==1){
            finish();
        }else {
            super.onBackPressed();
        }
    }
}
